#region Usings

using System;
using Newtonsoft.Json;
using NHibernate.Proxy;

#endregion

namespace Karma.Framework.Core.Serialization.Json.Converters
{
    ///<summary>
    /// 
    ///</summary>
    public class NHibernateProxyJsonConverter : JsonConverter
    {
        /// <exception cref="NotImplementedException"><c>NotImplementedException</c>.</exception>
        public override object ReadJson(JsonReader reader, Type objectType)
        {
            throw new NotImplementedException();
        }

        public override bool CanConvert(Type objectType)
        {
            return typeof (INHibernateProxy).IsAssignableFrom(objectType);
        }

        public override void WriteJson(JsonWriter writer, object value)
        {
            var serializer = new NHibernateProxyJsonSerializer();
            serializer.Serialize(writer, value);
        }
    }
}